# -*- coding: utf-8 -*-

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

from usuarios.decorators import login_required
from usuarios.views import auth_direct_to_template
from usuarios.views import auth_gridcrud_run as auth_run

from django.conf import settings

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$', auth_direct_to_template, {'template': 'index.html'}, name='index'),

    url(r'^webservices\.js$', direct_to_template, {'template': 'webservices.js', 'mimetype': 'text/javascript'}, name='webservices.js'),

    #Menus
    (r'^menu/', include('urls_menu')),

    #Usuário
    (r'^usuarios/', include('usuarios.urls')),

    #Recurso
    (r'^recurso/', include('sgr.urls')),
)

if not settings.IS_PRODUCTION:
    # Serving static files using django.
    # WARNING: This is inefficient, but handy in development server.
    # In production server, Apache itself should be configured to serve
    # these files.
    # http://docs.djangoproject.com/en/dev/howto/static-files/
    # settings.MEDIA_URL[1:] to remove the leading '/'
    urlpatterns.insert(0, url(r'^' + settings.MEDIA_URL[1:] + '(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))
    urlpatterns.insert(1, url(r'^' + settings.MEDIA_COMMON_URL[1:] + '(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_COMMON_ROOT}))

